﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;

public partial class KMrpt18 : ExtBaseRpt
{
    string mid;
    protected void Page_Load(object sender, EventArgs e)
    {
        mid = Request.Params["mid"];
        if (!X.IsAjaxRequest)
        {
            //BuildGridPanel(this.GridPanel1, mid, Session["UserID"].ToString());
            this.txtbdate.Text = DateTime.Now.AddDays(-7).ToString();
            this.txtedate.Text = DateTime.Now.ToString();
            this.txtStock.GetStore().DataSource = wmsdb.DM_GetDateSet("select stockid,stockname from bas_stock WHERE StockType = 0 order by stockname");
            this.txtPerson.GetStore().DataSource = wmsdb.DM_GetDateSet(@"SELECT DISTINCT p.PersonnelID,u.UserName FROM  Wms_PickTaskPerson p
                                                                        inner join Sys_User u on u.PersonnelID = p.PersonnelID");
            //this.txtbjhdate.Text = DateTime.Now.ToString("yyyy-MM-01");
            //this.txtejhdate.Text = DateTime.Now.ToString();
        }
    }
    
    protected void BtnQureyUser(object sender, DirectEventArgs e)
    {
        string bdate, edate;
        if (Convert.ToDateTime(txtbdate.Text) == Convert.ToDateTime("0001-01-01 00:00:00"))
            bdate = "";
        else
            bdate = txtbdate.Text;

        if (Convert.ToDateTime(txtedate.Text) == Convert.ToDateTime("0001-01-01 00:00:00"))
            edate = "";
        else
            edate = txtedate.Text;
        string tasktype = StrSplitParam(cbtype);
        this.Store1.DataSource = wmsdb.DM_GetDateSet("KM_Wms_PickTaskRpt '" + bdate + "','" + edate + "','"
            + this.txtBillNO.Text + "','" + this.txtStock.Value + "','" + this.txtPerson.Value+ "','"+tasktype+"'");
        this.Store1.DataBind();
    }


    protected void RefreshDataSet(object sender, StoreReadDataEventArgs e)
    {
        BtnQureyUser(null,null);
    }
    protected void Store1_Submit(object sender, StoreSubmitDataEventArgs e)
    {
        //导出EXCEL
        ExtGridToExcel(mid,"xls",e.Xml,this.Response,this.Title);
    }
}